// ps:代码参考官解
package main

func main() {
	aa := twoSum([]int{2, 7, 11, 15}, 9)
	println(aa)
}

// map的2种初始化方式
func twoSum(nums []int, target int) []int {
	// mp := map[int]int{}
	mp := make(map[int]int)
	for k, v := range nums {
		if val, ok := mp[target-v]; ok {
			return []int{k, val}
		}
		mp[v] = k
	}
	return nil
}
